<?php

namespace App\Http\Controllers;

use App\Models\ForumCategory;
use App\Models\ForumTopic;
use Illuminate\Http\Request;

class CategoriesController extends Controller
{
    public function show(ForumCategory $category,Request $request, ForumTopic $topic)
    {
        // 读取分类 ID 关联的话题，并按每 20 条分页
         $forum_topics = $topic ->withOrder($request->order)
                                ->where('category_id', $category->id)
                                ->paginate(20);
         $breadcrumb_categorys=$category;
         // 传参变量话题和分类到模板中
         return view('forum.forum_topics.index', compact('forum_topics', ['breadcrumb_categorys']));
    }
}
